<template>
  <div class="page-box h100 display-flex czbj">
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      imgkuTitle="康胜管理员头像"
    ></dxtable>
  </div>
</template>
 <script lang='ts' setup>
import { leixing } from "../../util/config";
import dxtable from "../../components/util/dxtable.vue";
import { dxget } from "../../util/index";
import { h, ref, reactive } from "vue";
let qxList = ref([]);
let dataJson = [
  {
    title: "头像",
    key: "headPortrait",
    type: "img", //类型
  },
  {
    title: "账号",
    key: "userNmae",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "昵称",
    key: "userNickname",
    search: true, // 是否在搜索栏展示
  },
  {
    title: "角色名称",
    key: "CharacterNameCode",
    render(row) {
      try {
        let ql = qxList.value.filter((a) => a.id == row.CharacterNameCode);
        return ql[0].name;
      } catch (e) {
        return "";
      }
    },
  },
  {
    title: "登录ip",
    key: "loadIp",
  },
  {
    title: "创建时间",
    key: "addTime",
  },
];
const qx = {
  DeletePermissionID: "ksuserManagementdel", //删除
  EditPermissionIdentifier: "ksuserManagementbj", // 编辑
  NewPermissionIdentifier: "ksuserManagementxz", // 新建
  ViewPermissionID: "ksuserManagementck", // 查看
};
// const portUrl = "dxgjAdmin/administrator?CharacterNameCode=" + leixing;
const portUrl = "dxgjAdmin/administrator?CharacterNameCode=32";
let formJson = reactive([
  {
    title: "管理员名",
    type: "input",
    key: "userNmae",
    required: true, // 是否为必填
  },
  {
    title: "管理员密码",
    type: "password",
    key: "userPassword",
    required: true, // 是否为必填
  },
  {
    title: "管理昵称",
    key: "userNickname",
    type: "input",
    required: true, // 是否为必填
  },
  {
    title: "角色名称",
    type: "select",
    key: "CharacterNameCode",
    val: 32,
    ishide: true,
    required: true, // 是否为必填
    options: [],
  },
  {
    title: "头像",
    key: "headPortrait",
    type: "img", //类型
    required: true, // 是否为必填
  },
]);
let optionsSele = [];
const getSelect = async () => {
  let { data }: any = await dxget("dxgjAdmin/rolemanagement");
  console.log(data);
  data.map((a) => {
    optionsSele.push({
      label: a.name,
      value: a.id,
    });
  });
  formJson[3].options = optionsSele;
  qxList.value = data;
};
getSelect();
</script>
 <style scoped>
</style>